import { Menu } from 'electron'
import { openAbout } from '.'

export const setup = () => {
  const template: any = [
    {
      label: '文件(&F)',
      submenu: [
        {
          label: '退出(&X)',
          role: 'quit', // 使用内置角色
        },
      ],
    },
    {
      label: '视图',
      submenu: [
        { label: '重载', role: 'reload' },
        { label: '强制重载', role: 'forceReload' },
        { label: '开发人员工具', role: 'toggleDevTools' },
        { type: 'separator' },
        { label: '重置', role: 'resetZoom' },
        { label: '放大', role: 'zoomIn' },
        { label: '缩小', role: 'zoomOut' },
        { label: '全屏', role: 'togglefullscreen' },
      ],
    },
    {
      label: '帮助',
      submenu: [
        {
          label: '关于',
          click: () => {
            openAbout()
          },
        },
      ],
    },
  ]
  const menu = Menu.buildFromTemplate(template)
  Menu.setApplicationMenu(menu)
}
